﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>"   %>
<%@ Import Namespace="Workflow.Model.Enum" %>
<%@ Import Namespace="Workflow.Resource" %>
<%@ Import Namespace="Workflow.Web.Common" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title><%=Global.ViewTiff%></title>
    <style type="text/css">
        #left
        {
            width: 80%;
            height: 800px;
            float: left;
        }
        .tiffclose
        {
            float: right;
        }
        #right
        {
            width: 18%;
            height: 800px;
            float: left;
            padding-left: 5px;
        }
        #right div
        {
            padding-bottom: 20px;
            border: 1px solid #8A9ABB;
            background: #F0F4F7;
            margin-bottom: 10px;
            font:Verdana, Geneva, sans-serif,宋体;
            font-size:12px;
        }
        body
        {
            scrollbar-face-color: #666666;
            scrollbar-highlight-color: #cccccc;
            scrollbar-shadow-color: #666666;
            scrollbar-3dlight-color: #666666;
            scrollbar-arrow-color: #f3e6a0;
            scrollbar-darkshadow-color: #444444;
        }
    </style>
    <link href="../../Scripts/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/mercktheme/jquery-1.4.4.min.js" type="text/javascript"></script>
    <script src="../../Scripts/mercktheme/jquery.easyui.min.js" type="text/javascript"></script>
    <script>
        function finish(pam) {
            
            $('#FinishFlag').val(pam);
             
            if(pam=="3")
            {
                $('#InvoiceNo').val($('#InvoiceNoPL').val());
            }
            $('#form').form('submit', {

                url: '/TIFF/FinishCaseEEM',
                //  url: '/TIFF/FinishCase?caseNo=' + id + "&InvoiceNo=" + InvoiceNo,
                success: function (data) {
                    eval('data=' + data);
                    if (data.Success) {
                        // _user_form.form('clear');
                        $.messager.alert('<%=Global.InfoTitle%>', data.Message, 'info');
                        window.location.reload();
                    } else {
                        $.messager.alert('<%=Global.ErrorTitle%>', data.Message, 'error');
                    }

                    // window.location = '/User/Index';
                },
                onSubmit: function () {
                    if (pam == "1" || pam == "3") {
                        //if (_user_form.valid())
                        if ($('#form').form('validate')) {
                            openWaitPage();
                        }
                        return $('#form').form('validate');
                    }
                    openWaitPage();
                    return true;
                    // return true;
                    // else
                    //    return false;
                }
            });
          
        }
        function reject(pam) {

            $('#FinishFlag').val(pam);

            $('#form').form('submit', {

                url: '/TIFF/RejectCaseEEM',
                success: function (data) {
                    eval('data=' + data);
                    if (data.Success) {
                        // _user_form.form('clear');
                        $.messager.alert('<%=Global.InfoTitle%>', data.Message, 'info');
                        window.location.reload();
                    } else {
                        $.messager.alert('<%=Global.ErrorTitle%>', data.Message, 'error');
                    }

                    // window.location = '/User/Index';
                    //$("#tt").datagrid('reload');
                },
                onSubmit: function () {
                    //if (_user_form.valid())
                    if (pam == "1") {
                        var RejectReason = $('#RejectReason').combobox('getValue');

                        if (RejectReason == "") {
                            $.messager.alert('<%=Global.InfoTitle%>', '<%=Global.pleaseInputRejectReason%>', 'InfoTitle');

                            return false;
                        }
                        if ($("#chkMail").attr("checked")) {
                            if ($('#email').val() == "") {
                                $.messager.alert('<%=Global.InfoTitle%>', '<%=Global.InputMail%>', 'InfoTitle');
                                return false;
                            }
                        }
                        if ($("#InvoiceNo").val() != "") {
                            if (!$('#form').form('validate')) {
                                return false;
                            }
                            else {
                                openWaitPage();
                                return true;
                            }
                        }
                        else {
                            openWaitPage();
                            return true;
                        }
                    }
                    else {

                        if (confirm('<%=Global.ConfirmSubmit%>')) {

                            openWaitPage();

                            return true;
                        }
                        else {

                            return false;
                        }
                    }
                }
            });

        }
        function pengding() {

            $('#form').form('submit', {

                url: '/TIFF/QACaseEEM',
                success: function (data) {
                    eval('data=' + data);
                    if (data.Success) {
                        // _user_form.form('clear');
                        $.messager.alert('<%=Global.InfoTitle%>', data.Message, 'info');
                        window.location.reload();
                    } else {
                        $.messager.alert('<%=Global.ErrorTitle%>', data.Message, 'error');
                    }

                    $("#StatusComment").val(decodeURI($("#StatusComment").val()));

                    // window.location = '/User/Index';
                    // $("#tt").datagrid('reload');
                },
                onSubmit: function () {
                    //if (_user_form.valid())
                    var RejectReason = $('#PengdingReason').combobox('getValue');

                    if (RejectReason == "") {
                        $.messager.alert('<%=Global.InfoTitle%>', '<%=Global.pleaseInputPendingReason%>', 'InfoTitle');
                        return false;
                    }
                    if ($("#chkMail").attr("checked")) {
                        if ($('#email').val() == "") {
                            $.messager.alert('<%=Global.InfoTitle%>', '<%=Global.InputMail%>', 'InfoTitle');
                            return false;
                        }
                    }

                    $("#StatusComment").val(encodeURI($("#StatusComment").val()));

                    if ($("#InvoiceNo").val() != "") {
                        if (!$('#form').form('validate')) {
                            return false;
                        }
                        else {
                            openWaitPage();
                            return true;
                        }
                    }
                    else {
                        openWaitPage();
                        return true;
                    }
                    // else
                    //    return false;
                }
            });

        }

        function NextCase() {
            $('#form').form('submit', {
                url: '/TIFF/NextCaseEEM',
                success: function (data) {
                    eval('data=' + data);
                    if (data.Success) {
                        window.location = '/tiff/indexeem?caseNo=' + data.CaseNo + '&NextCaseKeepStatus=' + data.NextCaseKeepStatus;
                    } else {
                        $.messager.alert('<%=Global.ErrorTitle%>', data.Message, 'error');
                    }
                },
                onSubmit: function () {
                    return true;
                }
            });

        }
        function closeForm() {
            if (window.opener.closed == false) {
                window.opener.location.reload();
            }
            window.close();
        }
        $(document).ready(function () {

            if ('<% =((Workflow.Model.CaseEEM) ViewData["Case"]).CaseNo%>' == '0') {

                $.messager.alert('<%=Global.InfoTitle%>', '<%=Global.NoCaseMessage%>', 'info', closeForm);

            }
            $('#SearchUser').linkbutton('disable');
            $('#UserID').attr("disabled", true);
            $('#email').attr("disabled", true);
            $('#email').val("");


                         <%
             string rolecode = Session[ConfigReader.AuthorizeSessionUserRoleCode].ToString();
            var tempCase= (Workflow.Model.CaseEEM) ViewData["Case"];

                    //PL load close data
                    if (rolecode == ((int)EnumRole.GPEEMPL).ToString() 
                    || rolecode == ((int)EnumRole.GPPTPPL ).ToString()
                    || rolecode == ((int)EnumRole.GPAHPTPPL).ToString()
                    || rolecode == ((int)EnumRole.GPAHEEMPL).ToString()
                    )
                    {
                    	if (tempCase.CaseMapPropertyEEM != null)
                    	{

                    		if (tempCase.CaseMapPropertyEEM.Payment != null)
                    		{
%>

                             $('#PaymentPL').combobox('setValue','<%=tempCase.CaseMapPropertyEEM.Payment.PaymentId%>');
                    

                <%
                    		}
                    	}
                    }
%>


        });

        function SearchUserMail() {

            $('#form').form('submit', {

                url: '/TIFF/GetApplicatMail',
                //  url: '/TIFF/FinishCase?caseNo=' + id + "&InvoiceNo=" + InvoiceNo,
                success: function (data) {
                    eval('data=' + data);
                    if (data.Success) {
                        // _user_form.form('clear');
                        $("#email").val(data.mail);
                        //$.messager.alert('<%=Global.InfoTitle%>', data.mail, 'info');
                        //window.location.reload();
                    } else {
                        //$.messager.alert('<%=Global.ErrorTitle%>', data.Message, 'error');
                    }

                    // window.location = '/User/Index';
                    $("#StatusComment").val(decodeURI($("#StatusComment").val()));
                },
                onSubmit: function () {
                    $("#StatusComment").val(encodeURI($("#StatusComment").val()));
                    //if (_user_form.valid())
                   
                    return true;
                    // return true;
                    // else
                    //    return false;
                }
            });

        }
        function SetMail() {
            if ($("#chkMail").attr("checked")) {
                $('#SearchUser').linkbutton('enable');
                $('#UserID').attr("disabled", false);
                $('#email').attr("disabled", false);
                $('#email').val("");
                $('#UserID').val("");
            }
            else {
                $('#SearchUser').linkbutton('disable');
                $('#UserID').attr("disabled", true);
                $('#email').attr("disabled", true);
                $('#email').val("");
                $('#UserID').val("");
                
            }
        }
        var isIE6 = $.browser.msie && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);
        (function ($) {
            $.OverLay = (function () { return function () { this.initialize.apply(this, arguments); } })();
            $.OverLay.prototype = {
                initialize: function (options) {

                    this.SetOptions(options);
                    this.Lay = $(document.createElement("div"));
                    $('body').append(this.Lay)
                    this.Color = this.options.Color;
                    this.Opacity = parseInt(this.options.Opacity);
                    this.zIndex = parseInt(this.options.zIndex);
                    this.Lay.css({ display: "none", zIndex: this.zIndex, left: 0, top: 0, position: "fixed", width: "100%", height: "100%" })
                    if (isIE6) {
                        this.Lay.css({ position: "absolute" });
                        this._resize = (function (object, fun) {
                            return function () {
                                return fun.apply(object, arguments);
                            }
                        })(this, function () {
                            this.Lay.css({ width: Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px", height: Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px" });
                        })

                        this.Lay.html('<iframe style="position:absolute;top:0;left:0;width:100%;height:100%;filter:alpha(opacity=0);"></iframe>');

                    }
                },
                SetOptions: function (options) {
                    this.options = { Color: "#666", Opacity: 50, zIndex: 1000 };
                    jQuery.extend(this.options, options || {});
                },
                Show: function () {
                    if (isIE6) { this._resize(); $(window).resize(this._resize) }
                    this.Lay.css({ backgroundColor: this.Color, display: "block", position: "absolute" })
                    if ($.browser.msie) { this.Lay.css({ filter: "alpha(opacity:" + this.Opacity + ")" }) } else { this.Lay.css({ opacity: this.Opacity / 100 }) }
                },
                Close: function () {
                    this.Lay.css({ display: "none" });
                    if (isIE6) { $(window).resize(function () { }) }
                }
            };
        })(jQuery)
        function openWaitPage() {
            o = new $.OverLay({ Opacity: 50, Color: '#eee' });
            o.Show();

        }
    </script>
</head>
<body>
    <div id="left" style="width: 84%">
        <% =ViewData["content"]%>
    </div>
    <div id="right" style="display: inline; width: 15%; float: right">
    
    <form id="form" method="post">
    <%


    	var showCheckOne = "";
    	var showCheckTwo = "";
    	var vCase = (Workflow.Model.CaseEEM) ViewData["Case"];
    	var type = " ";
    	var showCommont = "";
    	var showPLWork = true;
    	var shownextCase = "";
    	var PLCommont = "";
    	string role = Session[ConfigReader.AuthorizeSessionUserRoleCode].ToString();

    	//PL WORK
    	if (role == ((int) EnumRole.GPEEMPL).ToString() 
            || role == ((int) EnumRole.GPPTPPL).ToString()
            || role == ((int)EnumRole.GPAHPTPPL).ToString()
            || role == ((int)EnumRole.GPAHEEMPL).ToString())
     {
     	showCheckOne = "style='display:none;'";
     	showCheckTwo = "style='display:none;'";
     	shownextCase = "style='display:none;'";
     	PLCommont = vCase.StatusComment;
     }
     else // PA
     {
     	showPLWork = false;

     	if (vCase != null && vCase.WorkStatus != null)
     	{
     		if (vCase.WorkStatus.WorkStatusCode == ((int) EnumWorkStatus.WaitForCheck).ToString())
     		{
     			showCheckOne = "style='display:none;'";
     		}
     		else if (vCase.WorkStatus.WorkStatusCode == ((int) EnumWorkStatus.Distributed).ToString() ||
     		         vCase.WorkStatus.WorkStatusCode == ((int) EnumWorkStatus.Pending_QA).ToString())
     		{
     			showCheckTwo = "style='display:none;'";
     		}
     		else
     		{
     			showCheckOne = "style='display:none;'";
     			showCheckTwo = "style='display:none;'";
     			showCommont = "style='display:none;'";
     		}

     		if (vCase.Operator != null)
     		{
     			if (vCase.Operator.UserID.ToString() != Session[ConfigReader.AuthorizeSessionUserID].ToString())
     			{
     				showCheckOne = "style='display:none;'";
     				showCheckTwo = "style='display:none;'";
     				type = "disabled = 'true'";
     				showCommont = "style='display:none;'";
     			}
     		}
     		else
     		{
     			showCheckOne = "style='display:none;'";
     			showCheckTwo = "style='display:none;'";
     			type = "disabled = 'true'";
     			showCommont = "style='display:none;'";
     		}
     	}
     	else
     	{
     		showCheckOne = "style='display:none;'";
     		showCheckTwo = "style='display:none;'";
     		type = "disabled = 'true'";
     		showCommont = "style='display:none;'";
     	}
     }

%>
        <div id="tiffinfo">
            <input type="hidden" id="caseNo" name="caseNo" value="<% =vCase.CaseNo%>"/>
            <input type="hidden" id="FinishFlag" name="FinishFlag"  />
           <input type="hidden" id="NextCaseKeepStatus" name="NextCaseKeepStatus" value="<% =ViewData["NextCaseKeepStatus"]%>" />
            
            
            <b><font size="2"><%=Global.Information%>  :</font>  </b>
            <br />
            <%=Global.FileName%>：
            <% =vCase.FileName%><br />
             <%
    	if (vCase.InvoiceNo != null)
     {%>
            <%=Global.InvoiceNoEEM%>:<% =vCase.InvoiceNo%><br/>
            <%
     }%>
             <%
    	if (vCase.FolderLevelA != null)
     {%>
            <%=Global.FolderLevelA%>:<% =vCase.FolderLevelA.FolderName%>
             <br />
             <%
     }%>
           
            <%
    	if (vCase.FolderLevelB != null)
     {%>
            <%=Global.FolderLevelB%>:<% =vCase.FolderLevelB.FolderName%>
            <br />
            <%
     }%>

            <%
    	if (vCase.CheckType != null)
     {%>
            <%=Global.CheckType%>:<% =vCase.CheckType.FolderName%>
            <br />
            <%
     }%>

                 <%
    	if (vCase.WorkStatus != null)
     {%>
            <%=Global.WorkStatus%>:<% =vCase.WorkStatus.WorkStatusNameEEM%>
            <br />
            <%
     }%>
            
        

                   <%
    	if (vCase.CaseMapPropertyEEM != null)
     {

     	if (vCase.CaseMapPropertyEEM.Payment != null)
     	{
%>
            <%=Global.PaymentEEM%>:<% =vCase.CaseMapPropertyEEM.Payment.PaymentName%>
            <br />
            <%
     	}
     }
%>
            <%
    	if (vCase.CommentCode != null)
     {
%>
            <%=Global.ReasonTitle%>:<% =vCase.CommentCode.JpReason%>
            <br />
            <%
     }

%>
       <%if (vCase.BatchNo != null)
              {
%>
            <%=Global.BatchNo%>:<% =vCase.BatchNo.Substring(9,4)%>
            <br />

            <%
              }
                %>
 <%
     if (showCheckTwo == "")
     {
     	if (vCase.StatusOperator != null)
     	{%>
            <%=Global.StatusOperatorEEM%>:<% =vCase.StatusOperator.UserName%>
            <br />
            <%
     	}
     }%>

    <%if (vCase.StatusComment != null)
              {%>
            <%=Global.StatusComment%>:<% = vCase.StatusComment%>
            <br />
            <%
                }%>
        </div>

        <div <%=showCommont %> id="divStatusComment" >
         <%=Global.Comment%>:<br />
            <textarea id="StatusComment"  rows="3" name="StatusComment" wrap="wrap" style="ime-mode:active"><%=PLCommont %></textarea>
        </div>
        <div <%=showCheckOne %>>
        <%
           
             %>
            <%=Global.InvoiceNoEEM%>:<br />
            <input id="InvoiceNo"  class="easyui-validatebox" required="true"
               validType="length[10,10]" maxlength="10" name="InvoiceNo"  type="text" value="<% = vCase.InvoiceNo%>"  style="ime-mode:inactive"/>
            <br />
              <%=Global.PaymentEEM%>:<br />
              <input id="Payment" name="Payment" class="easyui-combobox" style="width: 110px" url="/TIFF/GetPayments?caseType=2"
                    valuefield="PaymentId" textfield="PaymentName" editable="false"><br />
             <a href="javascript:void(0)" class="easyui-linkbutton"   <%=type %> onclick="finish('1');"><%=Global.Finish%></a>
        </div>
        <div <%=showCheckOne %>>
           
             <%=Global.RejectReason%>:<br />
            <input id="RejectReason" name="RejectReason" class="easyui-combobox" style="width: 150px" valuefield="Id"
                    textfield="JpReason" multiple="false" editable="false" url="/TIFF/GetRejectReason?caseType=2">
            <br />
             <a href="javascript:void(0)" class="easyui-linkbutton"   <%=type %> onclick="reject('1');"><%=Global.Reject%></a>
        </div>

        <div  <%=showCheckOne %> >
           
             <%=Global.PengdingReason%>:<br />
            <input id="PengdingReason" name="PengdingReason" class="easyui-combobox" style="width: 150px" valuefield="Id"
                    textfield="JpReason" multiple="false" editable="false" url="/TIFF/GetPengdingReason?caseType=2">

            <br />

                        <a href="javascript:void(0)" class="easyui-linkbutton"   <%=type %> onclick="pengding();"><%=Global.Pengding%></a>
           
        </div>
         <div <%=showCheckOne %>>
            <%=Global.SendMail%>:
            <input id="chkMail" name="chkMail" type="checkbox" onclick="SetMail();"/>
            <br />

              <%=Global.ID%>:<br />
             <input id="UserID" name="UserID"  style="ime-mode:inactive" >
             <br />
             
            <a href="javascript:void(0)" class="easyui-linkbutton"   <%=type %> onclick="SearchUserMail();"><%=Global.Search%></a>
             <br />
             <%=Global.Email%>:<br />
             <input id="email" name="email"  style="ime-mode:inactive" >
           
            <br />

            </div>
         <div <%=showCheckTwo %> >
<br/>
            <a href="javascript:void(0)" class="easyui-linkbutton" <%=type%> icon="icon-ok"  onclick="finish('2');">
                <%=Global.Pass%></a>
<br/>
<br/>
<br/>
<br/>
            <a href="javascript:void(0)" class="easyui-linkbutton" <%=type%> icon="icon-no" onclick="reject('2');">
                <%=Global.Failed%></a>
        </div>
        <% if (showPLWork)
           {%>
        <div >
        
            <%=Global.InvoiceNoEEM%>:<br />
            <input id="InvoiceNoPL"  class="easyui-validatebox" required="true"
               validType="length[10,10]" maxlength="10" name="InvoiceNoPL"  type="text" value="<% =vCase.InvoiceNo%>"  style="ime-mode:inactive"/>
            <br />
             <%=Global.PaymentEEM%>:<br />
              <input id="PaymentPL" name="PaymentPL" class="easyui-combobox" style="width: 110px" url="/TIFF/GetPayments?caseType=2"
                    valuefield="PaymentId" textfield="PaymentName" editable="false"><br />

            <a href="javascript:void(0)" class="easyui-linkbutton"   <%=type%> onclick="finish('3');"><%=Global.Finish%></a>
        
        </div>
        <%
           }%>
        <div>
         <%
              var nextCaseType = "disabled = 'true'";
              if (vCase.CaseNo != 0)
              {
                  nextCaseType = " ";
              }
              %>
             <a href="javascript:void(0)" class="easyui-linkbutton" <%=shownextCase %>   <%=nextCaseType %> onclick="NextCase();" ><%=Global.NextCase%></a>
            <br />
            <br />
           <a href="javascript:void(0)" class="easyui-linkbutton" icon="icon-ok"   onclick="closeForm();" ><%=Global.Return%></a>
          
        </div>
        </form>
    </div>
</body>
</html>
